package com.example.mapper;

import com.example.enums.BookStatus;
import com.example.model.BookInfo;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * Description:
 * User: 阿宾
 * Date: 2025-04-22
 * Time: 15:30
 */
@Mapper
public interface BookInfoMapper {


    /**
     * 增加图书
     */
    @Insert("insert into book_info(book_name,author,count,price,publish,status) values " +
            "(#{bookName},#{author},#{count},#{price},#{publish},#{status})")
    Integer insertBook(BookInfo bookInfo);



    @Select("select * from book_info where status != 0 limit #{offset},#{limit}")
    List<BookInfo> selectBookPage(@Param("offset") Integer offset, @Param("limit") Integer limit);


    @Select("select count(1) from book_info where status != 0")
    Integer count();

    @Select("select * from book_info where id = #{id}")
    BookInfo queryBookById(Integer id);


    Integer updateBook(BookInfo bookInfo);


    @Update("update book_info set status = 0 where id = #{id}")
    Integer deleteBook(Integer id);

    Integer batchDeleteBook(@Param("bookIds") List<Integer> bookIds);
}
